package day12.tarena.com.cllection;

import java.util.HashMap;
import java.util.Scanner;

public class Example_2 {
	public static void main(String args[]) {
		Scanner sca = new Scanner(System.in);
		HashMap hm = new HashMap();
		System.out.println("Please enter your name:");
		String name = sca.next();
		String nameReg = "^[0-9A-Za-z]{5,8}$";
		if (!name.matches(nameReg)) {
			System.out.println("你输入的姓名格式不正确！！");
			return;
		}
		System.out.println("Please enter your password");
		String password1 = sca.next();
		String passwordReg = "^[0-9A-Za-z]{5,8}$";
		if (!password1.matches(passwordReg)) {
			System.out.println("Your password formart is error!");
			return;
		}
		System.out.println("Please enter your password agin");
		String password2 = sca.next();
		if (!password1.equals(password2)) {
			System.out.println("你两次输入的密码不一样！");
		}
		System.out.println("Please enter your Email:");
		String email = sca.next();
		String emailReg = "^[0-9A-Za-z]|\\\\@|.net|.com|.com.cn|.org$";
		hm.put("name", name);
		hm.put("password", password2);
		hm.put("ema", email);
		System.out.println(hm);
	}
}

// HashMap hm = new HashMap();
// hm.put("one",1); //1自动装箱为Integer对象
// hm.put("two",2);
// hm.put("three",3);
// hm.put("four",4); //key相同，替换value
// hm.put("two","我是新的two"); //Key是不能重复的，value可以 。
// System.out.println(hm.size()); //
// System.out.println(hm);
// hm.remove("three");
// Set set = hm.keySet();//取出元素
// for(Object key:set){ //for(元素的类型 ： 集合或者数组）｛｝
// Object value = hm.get(key);
// System.out.println(key+":"+value);
// // }
// // }